package com.itheima.拓展练习;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class Test03 {
    public static void main(String[] args) throws InterruptedException {
        ConcurrentHashMap<Integer,Integer> chm = new ConcurrentHashMap();

        new Thread(()->{
            for (int i = 0; i < 10000; i++) {
                chm.put(i,i);
            }
        }).start();
        new Thread(()->{
            for (int i = 10000; i < 20001; i++) {
                chm.put(i,i);
            }
        }).start();
        System.out.println("-------------");
        Thread.sleep(3000);
        Set<Map.Entry<Integer, Integer>> entries = chm.entrySet();
        for (Map.Entry<Integer, Integer> entry : entries) {
            Integer key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+" "+value);
        }
    }
}
